package com.mezz.bones.bff.app.adapter.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mezz.bones.framework.base.domain.response.Result;
import com.mezz.bones.user.application.domain.cmd.SysRoleCreateCmd;
import com.mezz.bones.user.application.domain.cmd.SysRoleDeleteCmd;
import com.mezz.bones.user.application.domain.cmd.SysRoleUpdateCmd;
import com.mezz.bones.user.application.domain.qry.SysRolePageForAppQry;
import com.mezz.bones.user.application.domain.res.SysRoleDetailForAppResponse;
import com.mezz.bones.user.application.domain.res.SysRolePageForAppResponse;
import com.mezz.bones.user.application.executor.cmd.ISysRoleExecutor;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: zhuang
 * @Date: 2024/8/30 19:02
 * @Description: TODO
 * @Version: 1.0
 **/

@RestController
@RequestMapping("/app/role")
@Api("角色信息管理")
@AllArgsConstructor
public class UserRoleController {

    private final ISysRoleExecutor sysRoleExecutor;

    @PostMapping("/create")
    @ApiOperation("角色-新增")
    public Result<String> crete(@RequestBody SysRoleCreateCmd cmd) {

        sysRoleExecutor.execSysRoleCreateCmd(cmd);
        return Result.OK();
    }

    @PostMapping("/update")
    @ApiOperation("角色-修改")
    public Result<String> update(@RequestBody SysRoleUpdateCmd cmd) {

        sysRoleExecutor.execSysRoleUpdateCmd(cmd);
        return Result.OK();
    }

    @PostMapping("/delete")
    @ApiOperation("角色-删除")
    public Result<String> delete(@RequestBody SysRoleDeleteCmd cmd) {
        sysRoleExecutor.execSysRoleDeleteCmd(cmd);
        return Result.OK();
    }

    @GetMapping("/detail/{id}")
    @ApiOperation("用户角色-详情")
    public Result<SysRoleDetailForAppResponse> detail(@PathVariable("id") String id) {
        return Result.OK(sysRoleExecutor.detailForApp(id));
    }

    @GetMapping("/page")
    @ApiOperation("用户角色-列表-分页")
    public Result<Page<SysRolePageForAppResponse>> page(SysRolePageForAppQry qry) {
        return Result.OK(sysRoleExecutor.pageForApp(qry));
    }
}
